package org.jivesoftware.smackx.packet;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.StringUtils;

public class DiscoverItems extends IQ
{
  public static final String NAMESPACE = "http://jabber.org/protocol/disco#items";
  private final List<Item> items = new CopyOnWriteArrayList();
  private String node;

  public void addItem(Item paramItem)
  {
    synchronized (this.items)
    {
      this.items.add(paramItem);
    }
  }

  public void addItems(Collection<Item> paramCollection)
  {
    if (paramCollection == null)
      return;
    Iterator localIterator = paramCollection.iterator();
    while (localIterator.hasNext())
    {
      Item localItem = (Item)localIterator.next();
      addItem(localItem);
    }
  }

  public Iterator<Item> getItems()
  {
    synchronized (this.items)
    {
      return Collections.unmodifiableList(this.items).iterator();
    }
  }

  public String getNode()
  {
    return this.node;
  }

  public void setNode(String paramString)
  {
    this.node = paramString;
  }

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<query xmlns=\"http://jabber.org/protocol/disco#items\"");
    if (getNode() != null)
    {
      localStringBuilder.append(" node=\"");
      localStringBuilder.append(StringUtils.escapeForXML(getNode()));
      localStringBuilder.append("\"");
    }
    localStringBuilder.append(">");
    synchronized (this.items)
    {
      Iterator localIterator = this.items.iterator();
      while (localIterator.hasNext())
      {
        Item localItem = (Item)localIterator.next();
        localStringBuilder.append(localItem.toXML());
      }
    }
    localStringBuilder.append("</query>");
    return localStringBuilder.toString();
  }

  public static class Item
  {
    public static final String UPDATE_ACTION = "update";
    public static final String REMOVE_ACTION = "remove";
    private String entityID;
    private String name;
    private String node;
    private String action;

    public Item(String paramString)
    {
      this.entityID = paramString;
    }

    public String getEntityID()
    {
      return this.entityID;
    }

    public String getName()
    {
      return this.name;
    }

    public void setName(String paramString)
    {
      this.name = paramString;
    }

    public String getNode()
    {
      return this.node;
    }

    public void setNode(String paramString)
    {
      this.node = paramString;
    }

    public String getAction()
    {
      return this.action;
    }

    public void setAction(String paramString)
    {
      this.action = paramString;
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<item jid=\"").append(this.entityID).append("\"");
      if (this.name != null)
        localStringBuilder.append(" name=\"").append(StringUtils.escapeForXML(this.name)).append("\"");
      if (this.node != null)
        localStringBuilder.append(" node=\"").append(StringUtils.escapeForXML(this.node)).append("\"");
      if (this.action != null)
        localStringBuilder.append(" action=\"").append(StringUtils.escapeForXML(this.action)).append("\"");
      localStringBuilder.append("/>");
      return localStringBuilder.toString();
    }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smackx.packet.DiscoverItems
 * JD-Core Version:    0.6.1
 */